package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.CouponProductRelation;
import com.itheima.mapper.CouponProductRelationMapper;
import com.itheima.service.SmsCouponProductRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class SmsCouponProductRelationServiceImpl implements SmsCouponProductRelationService {

    @Autowired
    CouponProductRelationMapper smsCouponProductRelationMapper;

    //优惠卷绑定的商品
    // 添加商品
    @Override
    public void save(CouponProductRelation smsCouponProductRelation) {
        smsCouponProductRelationMapper.insert(smsCouponProductRelation);
    }

    // 删除商品
    @Override
    public void delete(Integer id) {
        LambdaQueryWrapper<CouponProductRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(CouponProductRelation::getCouponId, id);
        smsCouponProductRelationMapper.delete(lqw);
    }

    //获取商品集合
    @Override
    public List<CouponProductRelation> selectyId(Long id) {
        LambdaQueryWrapper<CouponProductRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(CouponProductRelation::getCouponId, id);
        List<CouponProductRelation> selectList = smsCouponProductRelationMapper.selectList(lqw);
        return selectList;
    }
}
